﻿@using Smartstore.Web.Models.Catalog
@using Smartstore.Core.Checkout.Cart

@model ProductDetailsModel

@{
    var toCart = Model.AddToCart;
    var showBuyAction = Model.IsAvailable && !toCart.DisableBuyButton;
}

<div class="row flex-nowrap pd-offer-actions">
    @if (showBuyAction)
    {
        if (Model.Price.CallForPrice)
        {
            <div class="quote-request">
                <button type="button"
                        class="btn btn-secondary btn-lg btn-block action-ask-question" 
                        data-href="@Url.Action("AskQuestionAjax", "Product", new { id = Model.Id })"
                        data-form-selector="#pd-form">
                    <i class="fa fa-envelope" aria-hidden="true"></i>
                    <span>@T("Products.CallForPrice.GoToForm")</span>
                </button>
                <div sm-if="Model.HotlineTelephoneNumber.HasValue()" class="quote-request-hotline">
                    <div>@T("Products.AskQuestion.CallHotline")<i class="fas fa-phone-flip px-1" aria-hidden="true"></i><span class="fwm">@Model.HotlineTelephoneNumber</span></div>
                </div>
            </div>
        }
        else
        {
            <div sm-if="!toCart.HideQuantityControl && !toCart.CollapsibleAssociatedProduct" class="col-auto pd-offer-action-qty">
                @Html.EditorFor(model => model.AddToCart, "QtyInput", new { large = true, htmlAttributes = new { aria_label = T("Products.Qty") }})
            </div>        
            <div sm-if="!toCart.CollapsibleAssociatedProduct" class="col">
                <span sm-if="toCart.AddToCartSummary.HasValue()" id="pd-addtocart-desc" class="sr-only">@toCart.AddToCartSummary</span>
                <button type="button"
                        class="btn btn-primary btn-lg btn-block btn-add-to-cart ajax-cart-link"
                        data-href='@Url.Action("AddProduct", "ShoppingCart", new { productId = toCart.ProductId, shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart })'
                        data-form-selector="#pd-form"
                        data-type="cart"
                        data-action="add"
                        data-toggle="offcanvas" 
                        data-target="#offcanvas-cart"
                        attr-aria-describedby='(toCart.AddToCartSummary.HasValue(), "pd-addtocart-desc")'>
                    <i class="fa fa-cart-arrow-down d-none d-sm-inline-block d-md-none d-xl-inline-block" aria-hidden="true"></i>
                    <span>@T(toCart.AvailableForPreOrder ? "ShoppingCart.PreOrder" : "ShoppingCart.AddToCart")</span>
                </button>
            </div>
        }
    }
</div>